import Vue from 'vue'
import App from './App'
//全局变量
import store from './store'
Vue.prototype.$store = store;
// 请求
import request from '@/common/lib/request.js';
Vue.prototype.$request = request;
// 接口api
import api from '@/common/lib/api.js';
Vue.prototype.$api = api;
// 常用工具
import tools from '@/common/lib/tools.js';
Vue.prototype.$tools = tools;
Vue.config.productionTip = false
// 图片域名
Vue.prototype.imgUrl = 'https://api.mo-yu.vip' || function() {
	var imgUrl = 'https://api.mo-yu.vip'
	return imgUrl;
};
Vue.prototype.backPage = function(num) {
	console.log(num)
	uni.navigateBack({
		delta:num
	})
}
Vue.prototype.goPage = function(url) {
	uni.navigateTo({
		url
	})
}
Vue.prototype.previewImage = function(current, urls) {
	console.log(current)
	console.log(urls)
	let imgUrls = []
	if (!urls) {
		imgUrls.push(current)
	} else {
		imgUrls = urls
	}
	uni.previewImage({
		current,
		urls: imgUrls
	})
}
App.mpType = 'app'

//系统错误捕获
const errorHandler = (error, vm) => {
	console.error('抛出全局异常');
	console.log(vm);
	console.log('错误：' + error);
}
Vue.config.errorHandler = errorHandler;
Vue.prototype.$throw = (error) => errorHandler(error, this);

const app = new Vue({
	store,
	...App
})
app.$mount()
